﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FlashCards.Model;

namespace FlashCards.WebApp.Models
{
    public class FriendshipsModel
    {
        public List<FriendModel> Friends { get; set; }
        public List<FriendModel> InvitedUsers { get; set; }
        public List<FriendModel> SearchedUsers { get; set; }


        public FriendshipsModel()
        {
            Friends = new List<FriendModel>();
            InvitedUsers = new List<FriendModel>();
            SearchedUsers = new List<FriendModel>();
        }

        public FriendshipsModel(List<User> friends, List<User> invitedUsers, List<User> searchedUsers)
        {
            if (friends != null && friends.Count > 0)
            {
                Friends = new List<FriendModel>();
                Friends.AddRange(
                    friends.Select(x => new FriendModel(x)));
            }

            if (invitedUsers != null && invitedUsers.Count > 0)
            {
                InvitedUsers = new List<FriendModel>();
                InvitedUsers.AddRange(
                    invitedUsers.Select(x => new FriendModel(x)));
            }

            if (searchedUsers != null && searchedUsers.Count > 0)
            {
                SearchedUsers = new List<FriendModel>();
                SearchedUsers.AddRange(
                    searchedUsers.Select(x => new FriendModel(x)));
            }
        }
    }
}